package org.testfire.realm.view.tags.util;

import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.*;

/**
 * Created by IntelliJ IDEA.
 * User: Granum
 * Date: Dec 17, 2006
 * Time: 2:39:02 PM
 */
public class JavaScriptUtilities
{

    private static final SimpleDateFormat JS_DATE_TIME_FORMAT = new SimpleDateFormat( "MM/dd/yyyy HH:mm:ssZ" );
    //@todo This should be user-locale specific - NOT the server locale! 
    private static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss" );

    private JavaScriptUtilities()
    {
    }

    public static String toJSDateTime( Date dateTime )
    {
        return JS_DATE_TIME_FORMAT.format( dateTime );
    }

    public static String toJSDateTime( long dateTimeMillis )
    {
        return JS_DATE_TIME_FORMAT.format( new Date(dateTimeMillis) );
    }

   public static Date toDateTime( String js ) throws ParseException
   {
        return DATE_TIME_FORMAT.parse( js );
    }

    

    

}